package main

import "fmt"

func quickSort(arr []int) {
    if len(arr) <= 1 {
        return
    }
    pivot := arr[len(arr)/2]
    left, right := 0, len(arr)-1
    for left <= right {
        for arr[left] < pivot {
            left++
        }
        for arr[right] > pivot {
            right--
        }
        if left <= right {
            arr[left], arr[right] = arr[right], arr[left]
            left++
            right--
        }
    }
    quickSort(arr[:right+1])
    quickSort(arr[left:])
}

func main() {
    arr := []int{3, 6, 8, 10, 1, 2, 1}
    fmt.Println("Unsorted array:", arr)
    quickSort(arr)
    fmt.Println("Sorted array:", arr)
}